package com.rivulet.dawn.web.controller.database;

import com.rivulet.dawn.api.request.AllDeleteRequest;
import com.rivulet.dawn.api.request.archive.*;
import com.rivulet.dawn.api.response.archive.PostDataSearchResponse;
import com.rivulet.dawn.api.tools.Page;
import com.rivulet.dawn.api.tools.ResultFul;
import com.rivulet.dawn.service.service.archive.PostDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

@Api(value = "资料库管理", tags = "资料库管理")
@RestController
@RequestMapping("api/gateway/postData")
public class PostDataController {
    private final PostDataService postDataService;

    public PostDataController(PostDataService postDataService) {
        this.postDataService = postDataService;
    }

    @ApiOperation(value = "事件新增")
    @PostMapping("create")
    public ResultFul<Integer> create(@RequestBody PostDataSaveRequest request) {
        return ResultFul.OK(postDataService.save(request));
    }

    @ApiOperation(value = "事件删除")
    @PostMapping("delete")
    public ResultFul<Object> delete(@RequestBody AllDeleteRequest request) {
        postDataService.delete(request);
        return ResultFul.OK();
    }

    @ApiOperation(value = "资料库查询")
    @PostMapping("search")
    public ResultFul<Page<PostDataSearchResponse>> search(@RequestBody PostDataSearchRequest request) {
        return ResultFul.OK(postDataService.search(request));
    }
}
